package java_generics.bounded_type_parameters;

public class GenericMethodTest2 {
	// E for Element
	public static <E extends Number>
			Double sumArray(E[] inputArray) {
		Double sum = 0.0;

		for (E element : inputArray) {
			sum = sum + element.doubleValue();
		}

		return sum;
	}

	public static void main(String args[]) {
		// Create arrays of Integer, Double and Character
		Integer[] intArray = {1,2,3,4,5};
		Double[] doubleArray = {1.0,1.1,1.2,1.3};
		//Character[] charArray = {'J','A','V','A'};

		System.out.println(sumArray(intArray));
		System.out.println(sumArray(doubleArray));

		//sumArray( charArray ); // error we can pass only Numbers
	}
}
